//
//  StatusForwardCell.swift
//  MySinaWeiBo
//
//  Created by zhangfuwei on 15/8/6.
//  Copyright © 2015年 zhangfuwei. All rights reserved.
//

import UIKit

class StatusForwardCell: statusCell {
    
   override var status:Status? {
        didSet {
            let name = status?.retweeted_status?.user?.name ?? ""
            let text = status?.retweeted_status?.text ?? ""
            forwardLbl.text = "@" + "\(name)" + "\(text)"
            
        }
        
    }
 ///  重写 setupUI 方法
    override func setupUI() {
        super.setupUI()
        
        //  添加控件
        ///  视图配图/转发文字 lbl  都在 backButton 控件上面,
        contentView.insertSubview(backButton, belowSubview: pictureV)
        contentView.insertSubview(forwardLbl, aboveSubview: backButton)
        
        
        //  设置约束
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLable, size: nil, offset: CGPoint(x: -statusCellControlMargin, y: statusCellControlMargin))

        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: buttomV, size: nil)
        
        //  设置转发文本框约束
        forwardLbl.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: statusCellControlMargin, y: statusCellControlMargin))
        
        let cons = pictureV.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLbl, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: statusCellControlMargin))
        
        pictureHeightCons = pictureV.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureWidthCons = pictureV.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        
        pictureTopCons = pictureV.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
    
    //  MARK: 懒加载
    lazy var backButton:UIButton = {
       let btn = UIButton()
        
        btn.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        return btn
    }()
    
    
    
    lazy var forwardLbl:UILabel = {
       let lbl = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        lbl.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * statusCellControlMargin
        lbl.numberOfLines = 0
        return lbl
    }()
    
}
